<!DOCTYPE html>
<html lang="zh_CN" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<meta charset="utf-8">
<head th:include="include :: header"></head>
<body class="gray-bg">
<div class="wrapper wrapper-content ">
    <div class="col-sm-12">
       	<div class="ibox">
				<div class="ibox-body">
					<div class="fixed-table-toolbar">
						<div class="columns pull-left">
							<button shiro:hasPermission="experts:expertExpertsInfo:add" type="button"
								class="btn  btn-primary" onclick="add()">
								<i class="fa fa-plus hidden" aria-hidden="true"></i>新增
							</button>

							<button shiro:hasPermission="experts:expertExpertsInfo:edit" type="button"
									class="btn  btn-primary" onclick="edit()">
								<i class="fa fa-plus hidden" aria-hidden="true"></i>修改
							</button>
					
							<button shiro:hasPermission="experts:expertExpertsInfo:add" type="button"
								class="btn  btn-primary" onclick="location='/experts/expertExpertsInfo/exportExcel'">
								<i class="fa fa-plus hidden" aria-hidden="true"></i>导出
							</button>

							<button shiro:hasPermission="experts:expertExpertsInfo:add" type="button"
									class="btn  btn-primary" onclick="imports()">
								<i class="fa fa-plus hidden" aria-hidden="true"></i>导入
							</button>
				
							<button shiro:hasPermission="experts:expertExpertsInfo:batchRemove" type="button"
								class="btn  btn-danger" onclick="batchRemove()">
								<i class="fa fa-plus hidden" aria-hidden="true"></i>删除
							</button>
						</div>
						<!-- <div class="columns pull-left">
							<label class="control-label">审核状态：</label>
							<select  class="form-control" id="shztSelect" >
								<option  th:each="c:${application.jyrc_shzt__}"  th:value="${c.key}" th:text="${c.value}" ></option>
							</select>
						</div> -->
						<div class="columns pull-right">
							<button class="btn btn-success" onclick="reLoad()">查询</button>
						</div>

						<div class="columns pull-right col-md-2">
							<input id="searchName" type="text" class="form-control"
								placeholder="姓名|身份证号|手机号">
						</div>
					 	<div class="columns pull-right col-md-2 nopadding">
							<select data-placeholder="审核状态" class="form-control chosen-select" id="shztValue"
								tabindex="2" style="width: 100%">
								<option  th:each="c:${application.jyrc_shzt__}"  th:value="${c.key}" th:text="${c.value}" >审核状态</option>
							</select>
						</div> 
					</div>
					<table id="exampleTable" data-mobile-responsive="true">
					</table>
				</div>
			</div>
    </div>
</div>
</div>
<div th:include="include :: footer"></div>
<script type="text/javascript">
    var prefix = "/experts/expertExpertsInfo";
    $(function () {
        load();
    });

    function load() {
        $('#exampleTable')
            .bootstrapTable(
                {
                    method: 'get', // 服务器数据的请求方式 get or post
                    url: prefix + "/list", // 服务器数据的加载地址
                    //	showRefresh : true,
                    //	showToggle : true,
                    //	showColumns : true,
                    iconSize: 'outline',
                    toolbar: '#exampleToolbar',
                    striped: true, // 设置为true会有隔行变色效果
                    dataType: "json", // 服务器返回的数据类型
                    pagination: true, // 设置为true会在底部显示分页条
                    singleSelect: false, // 设置为true将禁止多选
                    // contentType : "application/x-www-form-urlencoded",
                    // //发送到服务器的数据编码类型
                    pageSize: 10, // 如果设置了分页，每页数据条数
                    pageNumber: 1, // 如果设置了分布，首页页码
                    //search : true, // 是否显示搜索框
                    showColumns: true, // 是否显示内容下拉框（选择显示的列）
                    sidePagination: "server", // 设置在哪里进行分页，可选值为"client" 或者 "server"
                    showToggle: true,//是否显示详细视图和列表视图的切换按钮
                    queryParamsType: "",
                    // //设置为limit则会发送符合RESTFull格式的参数
                    queryParams: function (params) {
                        var ascList = $(".asc");
                        if (ascList.length == 1) {
                            params.order = "asc";
                            params.sort = $(ascList[0]).parent().attr("data-field");
                        }
                        var descList = $(".desc");
                        if (descList.length == 1) {
                            params.order = "desc";
                            params.sort = $(descList[0]).parent().attr("data-field");
                        }
                        return {
                            //说明：传入后台的参数包括offset开始索引，limit步长，sort排序列，order：desc或者,以及所有列的键值对
                            pageNumber: params.pageNumber,
                            pageSize: params.pageSize,
                            sortOrder: params.order,//排序（desc，asc）
                            sortName: params.sort,//排序字段
                            shztValue:$('#shztValue').val(),
                            searchName: $('#searchName').val()
                        };
                    },
                    // //请求服务器数据时，你可以通过重写参数的方式添加一些额外的参数，例如 toolbar 中的参数 如果
                    // queryParamsType = 'limit' ,返回参数必须包含
                    // limit, offset, search, sort, order 否则, 需要包含:
                    // pageSize, pageNumber, searchText, sortName,
                    // sortOrder.
                    // 返回false将会终止请求
                    responseHandler: function (res) {
                        console.log(res);
                        return {
                            "total": res.data.total,//总数
                            "rows": res.data.records   //数据
                        };
                    },
                    columns: [
                        {
                            checkbox: true
                        },
                        {
                            field: 'id',
                            title: 'id',
                            sortable: true,
                            visible: false,
                            switchable: false
                        },
                        {
                            field: 'name',
                            title: '姓名',
                            sortable: true,
                            switchable: true
                        },
                        {
                            field: 'code',
                            title: '',
                            sortable: true,
                            visible: false,
                            switchable: false
                        },
                        {
                            field: 'gender',
                            title: '性别',
                            sortable: true
                        },
                        {
                            field: 'idcard',
                            title: '身份证',
                            width : '100px',
                            sortable: true
                        },
                        {
                            field: 'password',
                            title: '密码',
                            sortable: true,
                            visible: false,
                            switchable: true
                        },
                        {
                            field: 'birthday',
                            title: '生日',
                            width : '100px',
                            sortable: true,
                            visible: false,
                            switchable: true
                        },
                        {
                            field: 'record',
                            title: '学历',
                            sortable: true,
                            visible: false,
                            switchable: true
                        },
                        {
                            field: 'political',
                            title: '治政面貌',
                            sortable: true,
                            visible: false,
                            switchable: true
                        },
                        {
                            field: 'graduated',
                            title: '毕业学校',
                            sortable: true,
                            visible: false,
                            switchable: true
                        },
                        {
                            field: 'professional',
                            title: '专业',
                            sortable: true,
                            visible: false,
                            switchable: true
                        },
                        {
                            field: 'specialized',
                            title: '专技职务',
                            sortable: true,
                            visible: false,
                            switchable: true
                        },
                        {
                            field: 'subject',
                            title: '专技职务学科',
                            sortable: true,
                            visible: false,
                            switchable: true
                        },
                        {
                            field: 'qualification',
                            title: '教师资格证号',
                            sortable: true,
                            visible: false,
                            switchable: true
                        },
                        {
                            field: 'qualificationtype',
                            title: '教师资格类型',
                            sortable: true,
                            visible: false,
                            switchable: true
                        },
                        {
                            field: 'teachingsubjects',
                            title: '教师资格任教学科',
                            sortable: true,
                            visible: false,
                            switchable: true
                        },
                        {
                            field: 'accreditingagencies',
                            title: '认定机构',
                            sortable: true,
                            visible: false,
                            switchable: true
                        },
                        {
                            field: 'thecurrentteaching',
                            title: '现任教学段',
                            sortable: true,
                            visible: false,
                            switchable: true
                        },
                        {
                            field: 'nowteaching',
                            title: '现任教学科',
                            sortable: true,
                            visible: false,
                            switchable: true
                        },
                        {
                            field: 'issuper',
                            title: '是否特级教师',
                            sortable: true,
                            visible: false,
                            switchable: true,
                            formatter : function(value, row, index) {
                                if (value == '0') {
                                    return '<span class="label label-danger">否</span>';
                                } else if (value == '1') {
                                    return '<span class="label label-primary">是</span>';
                                }
                            }
                        },
                        {
                            field: 'administrativeduties',
                            title: '行政职务',
                            sortable: true,
                            visible: false,
                            switchable: true
                        },
                        {
                            field: 'workunits',
                            title: '工作单位',
                            sortable: true,
                            visible: false,
                            switchable: true
                        },
                        {
                            field: 'workunitsaddress',
                            title: '工作单位地址',
                            sortable: true,
                            visible: false,
                            switchable: true
                        },
                        {
                            field: 'workunitszipcode',
                            title: '工作单位邮编',
                            sortable: true,
                            visible: false,
                            switchable: true
                        },
                        {
                            field: 'workunitstel',
                            title: '工作单位电话',
                            sortable: true,
                            visible: false,
                            switchable: true
                        },
                        {
                            field: 'homeaddress',
                            title: '家庭地址',
                            sortable: true,
                            visible: false,
                            switchable: true
                        },
                        {
                            field: 'homezipcode',
                            title: '家庭邮编',
                            sortable: true,
                            visible: false,
                            switchable: true
                        },
                        {
                            field: 'hometel',
                            title: '家庭电话',
                            sortable: true,
                            visible: false,
                            switchable: true
                        },
                        {
                            field: 'email',
                            title: '邮箱',
                            sortable: true
                        },
                        {
                            field: 'phone',
                            title: '手机',
                            sortable: true
                        },
                        {
                            field: 'category',
                            title: '推荐类别',
                            sortable: true,
                            visible: false,
                            switchable: true
                        },
                        {
                            field: 'course',
                            title: '科目',
                            sortable: true,
                            visible: false,
                            switchable: true
                        },
                        {
                            field: 'level',
                            title: '师教等级',
                            sortable: true
                        },
                        {
                            field: 'schoollevel',
                            title: '学校等级',
                            sortable: true,
                            visible: false,
                            switchable: true
                        },
                        {
                            field: 'istrain',
                            title: '是否培训',
                            sortable: true,
                            visible: false,
                            switchable: true,
                            formatter : function(value, row, index) {
                                if (value == '0') {
                                    return '<span class="label label-danger">否</span>';
                                } else if (value == '1') {
                                    return '<span class="label label-primary">是</span>';
                                }
                            }
                        },
                        {
                            field: 'traintime',
                            title: '培训时间',
                            sortable: true,
                            visible: false,
                            switchable: true
                        },
                        {
                            field: 'exnumber',
                            title: '活动次数',
                            sortable: true,
                            visible: false,
                            switchable: true
                        },
                        {
                            field: 'workexperience',
                            title: '工作经验',
                            sortable: true,
                            visible: false,
                            switchable: true
                        },
                        {
                            field: 'areaid',
                            title: '所属区域',
                            sortable: true
                        },
                        {
                            field: 'recommendstate',
                            title: '推荐级别',
                            sortable: true,
                            visible: false,
                            switchable: true
                        },
                        {
                            field: 'bankcardtype1',
                            title: '银行卡1类型',
                            sortable: true,
                            visible: false,
                            switchable: true
                        },
                        {
                            field: 'bankcardcode1',
                            title: '银行卡1号码',
                            sortable: true,
                            visible: false,
                            switchable: true
                        },
                        {
                            field: 'bankcardtype2',
                            title: '银行卡2类型',
                            sortable: true,
                            visible: false,
                            switchable: true
                        },
                        {
                            field: 'bankcardcode2',
                            title: '银行卡2号码',
                            sortable: true,
                            visible: false,
                            switchable: true
                        },
                        {
                            field: 'status',
                            title: '审核状态',
                            sortable: true,
                            formatter : function(value, row, index) {
                                if (value == '0') {
                                    return '<span class="label label-danger">待审核</span>';
                                } else if (value == '1') {
                                    return '<span class="label label-primary">审核通过</span>';
                                } else if (value == '2') {
                                    return '<span class="label label-danger">审核不通过</span>';
                                }
                            }
                        },
                        {
                            field: 'lastLoginIp',
                            title: '上次登陆IP',
                            visible: false,
                            sortable: true
                        },
                        {
                            field: 'lastLoginTime',
                            title: '上次登陆时间',
                            sortable: true
                        },
                        {
                            field: 'nettrainstatus',
                            title: '培训状态',
                            sortable: true,
                            visible: false,
                            switchable: true
                        },
        				{
                            title : '操作',
                            field : 'name',
                            width : '100px',
                            align : 'center',
                            visible: true,
                            sortable: true,
                            switchable: true,
                            formatter : function(value, row, index) {
                            	if (row.status == '0') {
                                    return '<a class="btn btn-primary btn-sm " href="#" mce_href="#" title="审核"  onclick="shenhe(\''+ row.id+ '\')">审核</a>';
                                } else if (row.status == '1') {
                                	return '';
                                } else if (row.status == '2') {
                                	return '';
                                }
                            }
                        }]
                });
    }

    function reLoad() {
        $('#exampleTable').bootstrapTable('refresh');
    }

    function add() {
        parent.layer.open({
            type: 2,
            title: '增加',
            maxmin: true,
            shadeClose: false, // 点击遮罩关闭层
            area: ['800px', '520px'],
            content: prefix + '/add' // iframe的url
        });
    }
function shenhe(id) {
	$.ajax({
        cache: true,
        type: "get",
        url: "/experts/expertExpertsInfo/update",
        data: {'id' : id ,'status' : '1'},
        async: false,
        error: function (request) {
            parent.layer.alert("Connection error");
        },
        success: function (data) {
            if (data.code == 0) {
                parent.layer.msg("审核成功");
                reLoad();
            } else {
                parent.layer.alert(data.msg)
            }

        }
    });
}
    
    function edit() {
        var rows = $('#exampleTable').bootstrapTable('getSelections'); // 返回所有选择的行，当没有选择的记录时，返回一个空数组
        if (rows.length == 0 || rows.length > 1) {
            layer.msg("请选择一条要修改的数据");
            return;
        }
        var ids = new Array();
        // 遍历所有选择的行数据，取每条数据对应的ID
        $.each(rows, function (i, row) {
            ids[i] = row['id'];
        });
        parent.layer.open({
            type: 2,
            title: '编辑',
            maxmin: true,
            shadeClose: false, // 点击遮罩关闭层
            area: ['800px', '520px'],
            content: prefix + '/edit/' + ids[0] // iframe的url
        });
    }
    
    function imports() {
        parent.layer.open({
            type : 2,
            title : '导入',
            maxmin : true,
            shadeClose : false, // 点击遮罩关闭层
            area : [ '450px', '260px' ],
            content : prefix + '/importPage'
        });
    }

    function remove(id) {
        layer.confirm('确定要删除选中的记录？', {
            btn: ['确定', '取消']
        }, function () {
            $.ajax({
                url: prefix + "/remove",
                type: "post",
                data: {
                    'id': id
                },
                success: function (r) {
                    if (r.code == 0) {
                        layer.msg(r.msg);
                        reLoad();
                    } else {
                        layer.msg(r.msg);
                    }
                }
            });
        })
    }

    function batchRemove() {
        var rows = $('#exampleTable').bootstrapTable('getSelections'); // 返回所有选择的行，当没有选择的记录时，返回一个空数组
        if (rows.length == 0) {
            layer.msg("请选择要删除的数据");
            return;
        }
        layer.confirm("确认要删除选中的'" + rows.length + "'条数据吗?", {
            btn: ['确定', '取消']
            // 按钮
        }, function () {
            var ids = new Array();
            // 遍历所有选择的行数据，取每条数据对应的ID
            $.each(rows, function (i, row) {
                ids[i] = row['id'];
            });
            $.ajax({
                type: 'POST',
                data: {
                    "ids": ids
                },
                url: prefix + '/batchRemove',
                success: function (r) {
                    if (r.code == 0) {
                        layer.msg(r.msg);
                        reLoad();
                    } else {
                        layer.msg(r.msg);
                    }
                }
            });
        }, function () {

        });
    }
</script>
</body>
</html>